import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:xvideos/assets_tool/images.dart';
import 'package:xvideos/config/config.dart';
import 'package:xvideos/hj_utils/widget_utils.dart';
import 'package:xvideos/routers/jump_router.dart';

import '../hj_model/user/aw_info_resp.dart';
import '../tools_base/debug_log.dart';
import '../hj_utils/api_service/vid_service.dart';

class AwPermissionAlert extends StatefulWidget {
  AwPermissionAlert();

  @override
  State<StatefulWidget> createState() {
    return _AwPermissionAlertState();
  }
}

class _AwPermissionAlertState extends State<AwPermissionAlert> {
  static AwInfoResp? awInfoResp;
  bool isLoadingData = true;
  @override
  void initState() {
    super.initState();
  }

  void _loadData({bool retry = false}) async {
    try {
      awInfoResp = await VidService.fetchAwVipInfo();
      isLoadingData = false;
    } catch (e) {
      debugLog(e);
      if (retry) {
        _loadData(retry: false);
      } else {
        isLoadingData = false;
      }
    }
    if (mounted) setState(() {});
  }

  @override
  Widget build(BuildContext context) {
      return Container(
        color: Colors.black.withOpacity(0.4),
        child: BackdropFilter(
          filter: ImageFilter.blur(
            sigmaX: 20,
            sigmaY: 20,
          ),
          child: Center(
            child: Material(
              color: Colors.transparent,
              child: GestureDetector(
                behavior: HitTestBehavior.opaque,
                onTap: () => jumpToWalletPage(tabPosition: 0),
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    Image.asset('aw_warning.webp'.homePath, height: 96),
                    28.sizeBoxH,
                    Text(
                      '系统警告\n'
                          '【暗网】含有百万全球禁播封杀资源，全球\n'
                          '上流社会权贵的私密丑闻！\n\n'
                          '萝莉岛事件，N号房，暴力重口，巴以/俄\n'
                          '乌/中东战争，血腥缅北，呦呦破处，变态\n'
                          '恐怖，暗网交易，等稀缺资源！',
                      textAlign: TextAlign.center,
                      style: TextStyle(
                        color: Color(0xff810906),
                        fontSize: 16,
                        fontWeight: FontWeight.w500,
                      ),
                    ),
                    18.sizeBoxH,
                    Text(
                      "马上开通",
                      textAlign: TextAlign.center,
                      style: TextStyle(color: Colors.white, fontSize: 14, height: 1.5),
                    ),
                    Text(
                      "${Config.darkWebVipName}",
                      textAlign: TextAlign.center,
                      style: TextStyle(color: Color(0xff810906), fontSize: 14, height: 1.5),
                    ),
                    Text(
                      "进入世界的黑暗面",
                      textAlign: TextAlign.center,
                      style: TextStyle(color: Colors.white, fontSize: 14, height: 1.5),
                    ),
                    18.sizeBoxH,
                    InkWell(
                      onTap: () {
                        jumpToWalletPage(vipId: Config.darkWebVipId);
                      },
                      child: Container(
                        width: 136,
                        height: 38,
                        alignment: Alignment.center,
                        decoration: BoxDecoration(
                          color: Color(0xff810906),
                          borderRadius: BorderRadius.circular(38),
                        ),
                        child: Text(
                          '开通会员',
                          textAlign: TextAlign.center,
                          style: TextStyle(
                            color: Colors.white,
                            fontSize: 14,
                            fontWeight: FontWeight.w500,
                          ),
                        ),
                      ),
                    ),
                    30.sizeBoxH,
                    Text(
                      '此板块为黑客破解内容，真实稀缺资源，\n'
                          '可能会引起极度不适，请谨慎进入\n',
                      textAlign: TextAlign.center,
                      style: TextStyle(color: Colors.white.withOpacity(0.45), fontSize: 12),
                    ),
                  ],
                ),
              ),
            ),
          ),
        ),
      );
    }
}
